package sis.report;

import sis.studentinfo.CourseSession;
import static sis.report.ReportConstant.NEWLINE;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: alexander-kalden
 * Date: 9/12/12
 * Time: 12:10 PM
 * To change this template use File | Settings | File Templates.
 */
public class CourseReport {

    private List<CourseSession> sessions = new LinkedList<CourseSession> ();

    public void add(CourseSession session) {
        sessions.add(session);
    }

    public String text() {

        Collections.sort(sessions);

        StringBuilder builder = new StringBuilder();

        for (CourseSession session : sessions) {
            builder.append(
                session.getDepartment() + " " +
                session.getNumber() + NEWLINE);
        }
        return builder.toString();
    }
}
